﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using Ymca.Entities;

namespace Ymca.Web.Models.Profile
{
	public class EditProfileViewModel
	{
		private const string _usernamePattern = @"[A-Za-z0-9]+(?:[@. _-][A-Za-z0-9]+)*";
		private const string _namePattern = @"[A-Za-zА-Яа-я0-9]+(?:[ -][A-Za-zА-Яа-я0-9]+)*";
		private const string _emailPattern = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$";

		public string OriginalId { get; set; }

		//[Required]
		[Display(Name = "User name")]
		//[StringLength(60, MinimumLength = 3)]
		//[RegularExpression(_usernamePattern)]
		public string Id { get; set; }

		[Required]
		[Display(Name = "Email")]
		[RegularExpression(_emailPattern)]
		public string Email { get; set; }

		[Display(Name = "Name")]
		[RegularExpression(_namePattern)]
		public string Name { get; set; }

		[Display(Name = "Surname")]
		[RegularExpression(_namePattern)]
		public string Surname { get; set; }
		
		public string Info { get; set; }
		
		public bool Notify { get; set; }

		public EditProfileViewModel()
		{

		}

		public EditProfileViewModel(UserProfile profile)
		{
			OriginalId = profile.Id;
			Id = profile.Id;
			Email = profile.Email;
			Name = profile.Name;
			Surname = profile.Surname;
			Info = profile.Info;
			Notify = profile.Notify;
		}
	}
}